package org.springcloud.wisdom.amusement.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.*;
import org.springcloud.wisdom.amusement.entity.AmusementNotice;

import java.util.List;

@Mapper
public interface AmusementNoticeDao extends BaseMapper<AmusementNotice> {

//    //有两个查看 1.查看所有发布的，大屏上
//    @Select("select  * from notice where ispublic = 1")
//    public List<AmusementNotice> selectNotice();
//
//    //查看社团已经审核通过的公告
//    @Select("select  * from notice where ispublic = 1 and teamid = #{teamid}")
//    IPage<AmusementNotice> selectPubNoticePage(Page<?> page, @Param("teamid") Integer teamid);
//    // 2.查看一个社团所有状态的信息
//    @Select("select  * from notice where teamid = #{teamid}")
//    public List<AmusementNotice> selectTeamNotice(Integer teamid);
//    @Select("select  * from notice where teamid = #{teamid}")
//    IPage<AmusementNotice> selectTeamNoticePage(Page<?> page, @Param("teamid") Integer teamid);

        //查看社团未审核通过的公告
    @Select("select  * from notice where ispublic = '未审核' and type like '3%'")
    IPage<AmusementNotice> selectUnPubNoticePage(Page<?> page);
    //删除公告
    @Delete("delete from notice where id=#{id}")
    public int deleteNotice(Integer id);

    //添加公告
    @Insert("insert into notice(title,content,type,identity,ispublic,publishdt) VALUES(#{title},#{content},#{type},#{identity},'未审核',Now())")
    public int addNotice(AmusementNotice amusementNotice);

    //公告过审
    @Update("update notice set ispublic='同意' where id=#{id}")
    public int realAddNotice(Integer id);

    //公告驳回，告知原因
    @Update("update notice set ispublic='不同意',reason=#{reason} where id=#{id}")
    public int rejectNotice(AmusementNotice amusementNotice);

}
